package com.api.volunteer.controller;

import com.api.volunteer.util.Result;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 邹宇杰
 * @email 2901570623@qq.com
 * @date 2022/3/29 21:53
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result errorHandler(Exception e) {

        Result result = new Result();
        result.put("code", HttpStatus.BAD_REQUEST.value());
        result.put("message", e.getMessage());
        return result;

    }

}

